﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BTN04.DTO;
using System.Collections.Generic;
using BTN04.BUS;

namespace BTN04.Template
{
    public partial class USER : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoaiSanPhamBUS lspBUS = new LoaiSanPhamBUS();
                List<LoaiSanPhamDTO> _lstLoaiSanPham = new List<LoaiSanPhamDTO>();
                _lstLoaiSanPham = lspBUS.DanhSachLoaiSanPham();
                ddlListLoaiSanPham.DataSource = _lstLoaiSanPham;
                ddlListLoaiSanPham.DataMember = "MaLoaiSanPham";
                LoaiSanPhamDTO lspSTO = new LoaiSanPhamDTO();
                lspSTO.MaLoaiSanPham = 0;
                lspSTO.TenLoaiSanPham = "-- Chọn Loại San Phẩm --";
                _lstLoaiSanPham.Insert(0, lspSTO);
                ListItem item;//= new ListItem();
                for (int i = 0; i < _lstLoaiSanPham.Count; i++)
                {
                    item = new ListItem();
                    item.Text = _lstLoaiSanPham[i].TenLoaiSanPham;
                    item.Value = _lstLoaiSanPham[i].MaLoaiSanPham.ToString();
                    ddlListLoaiSanPham.Items.Add(item);
                }
            }
            if (Session["tennguoidung"]!= null)
            {
                lblTenNguoiDung.Text = Session["tennguoidung"].ToString();
            }
            HienThiSoLuong();
        }
        public void HienThiSoLuong()
        {
            lbsoluong.Text = CurrentContext.Cart.SoLuongHang().ToString();
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Session["tensanpham"] = txtTenSanPham.Text;
            Session["malsp"] = ddlListLoaiSanPham.SelectedValue;
            if (txtGiaTu.Text != "")
                Session["giatu"] = txtGiaTu.Text;
            else
                Session["giatu"] = 0;
            if (txtGiaDen.Text != "")
                Session["giaden"] = txtGiaDen.Text;
            else
                Session["giaden"] = 0;
            Response.Redirect("../USER/TimKiemSanPham.aspx");
        }

      
    }
}
